package cn.org.bjca.seal.esspdf.client.test;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.junit.Test;

import cn.org.bjca.seal.esspdf.client.utils.Base64Encoder;
import cn.org.bjca.seal.esspdf.client.message.*;
import cn.org.bjca.seal.esspdf.client.utils.*;

/***************************************************************************
 * <pre>PDF签章服务器客户端工具测试类</pre>
 * @文件名称:  ESSPDFClientToolTest.java
 * @包   路   径：  cn.org.bjca.seal.esspdf.client.test
 * @版权所有：北京数字认证股份有限公司 (C) 2013
 *
 * @类描述:  
 * @版本: V2.0
 * @创建人： wangwenc
 * @创建时间：2013-5-18 下午1:34:10
 ***************************************************************************/
public class ESSPDFClientToolTest extends AnyWriteClientToolTest {

	@Test
	public void testPdfSign() throws Exception { //PDF签章测试
		System.out.println("*******************12");
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("C:\\Users\\Liuyan\\Desktop\\temp\\设备证书\\加密包 - 副本.pdf"));//pdf字节数组
		String ruleNum = "5E9217F50C3E491D";//签章规则编号
		long begin = System.currentTimeMillis();
		ChannelMessage message = anySignClientTool.pdfSign(ruleNum, pdfBty);
		long end = System.currentTimeMillis();
		System.out.println("********************运行时间:" + (end - begin) / 1000f + "s");
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("C:\\Users\\Liuyan\\Desktop\\页面旋转\\180-out.pdf"), message.getBody());
		}
	}

	@Test
	public void testPdfSign_sealNum_policyNum() throws Exception {//PDF签章测试,自定义服务印章编号、签名策略编号
		System.out.println("*******************");
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("f:/bjbank2.pdf"));//pdf字节数组
		String ruleNum = "10F70D0942747AB5";//签章规则编号
		String serverSealNum = "719C15E9C6B7441B";//服务器印章编号
		String signPolicyNum = "111111";//签名策略编号
		ChannelMessage message = anySignClientTool.pdfSign(ruleNum, serverSealNum, signPolicyNum, pdfBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("f:/bjbank2-out12.pdf"), message.getBody());
		}
	}

	@Test
	public void testPdfSignList() throws Exception {//PDF批量签章测试
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("D:/借款合同.pdf"));//pdf字节数组
		List<String> ruleNumList = new ArrayList<String>();//
		String ruleNum = "5D241CD4254250DA";//签章规则编号列表
		ruleNumList.add(ruleNum);
		ruleNum = "5A4C17A825298D";//签章规则编号列表
		ruleNumList.add(ruleNum);
		ruleNum = "5E9217F50C3E491D";//签章规则编号列表
		ruleNumList.add(ruleNum);
		long begin = System.currentTimeMillis();
		ChannelMessage message = anySignClientTool.pdfSign(ruleNumList, pdfBty);
		long end = System.currentTimeMillis();
		System.out.println("********************运行时间:" + (end - begin) / 1000f + "s");
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("D:\\测试文档\\借款合同.pdf"), message.getBody());
		}
	}

	@Test
	public void testPdfSpeedSign() throws Exception {//PDF高速签名
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("f:/179K.pdf"));//pdf字节数组
		List<String> ruleNumList = new ArrayList<String>();//
		String ruleNum = "3A66581337633A4B";//签章规则编号列表
		ruleNumList.add(ruleNum);
		long begin = System.currentTimeMillis();
		ChannelMessage message = anySignClientTool.pdfSpeedSign(ruleNumList, pdfBty);
		long end = System.currentTimeMillis();
		System.out.println("********************运行时间:" + (end - begin) / 1000f + "s");
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("f:/179K-sign-en.pdf"), message.getBody());
		}
	}

	@Test
	public void testPdfVerify() throws Exception {//PDF验签测试
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("D:\\签名的申请表.pdf"));//pdf字节数组
		String orgCode = "123456";//机构代码
		ChannelMessage message = anySignClientTool.pdfVerify(orgCode, pdfBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		System.out.println("验证结果：" + new String(message.getBody(), "UTF-8"));
	}

	public static void main(String[] args) throws Exception {
		ESSPDFClientToolTest test = new ESSPDFClientToolTest();
		test.init();

		//		test.testPdfSign("借款合同-单章-RSA-out","1344721087C1330E");//5875677783620EE4
		//		test.testPdfSign("借款合同-单章-SM2-out","3FD238AFA89C2EA7");
		//		test.testPdfSign();
		//		test.testPdfSign("借款合同-骑缝-多页签-RSA-out","3492D9F9733C71B0");
		//		test.testPdfSign("借款合同-骑缝-多页签-SM2-out","4186EB6EC596EC28");
		//		test.testPdfSignList("借款合同-多章-RSA-SM2-out","5E9217F50C3E491D","59152E0A86CF2F5A");
		//		test.testPdfSignList("借款合同-多章-SM2-RSA-out","59152E0A86CF2F5A","5E9217F50C3E491D");

		//		test.testPdfVerify("BG_JDCJ");
		//		test.testPdfVerify("借款合同-单章-SM2-out");
		//		test.testPdfVerify("借款合同-骑缝-多页签-RSA-out");
		//		test.testPdfVerify("借款合同-骑缝-多页签-SM2-out");
		//		test.testPdfVerify("借款合同-多章-RSA-SM2-out");
		//		test.testPdfVerify("借款合同-多章-SM2-RSA-out");

		//加在线验证按钮
		//加密

		//两章之间加批准
		//章之后加批注
	}

	@Test
	public void testPdfVerifyForNoOrgCode() throws Exception {//PDF验签测试
		System.out.println("******************33");
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("D:\\测试文档\\借款合同_在线验证.pdf"));//pdf字节数组
		ChannelMessage message = anySignClientTool.pdfVerify(pdfBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			System.out.println("验证结果：" + new String(message.getBody(), "UTF-8"));
		} else {
			System.out.println("验证结果：" + new String(message.getBody(), "UTF-8"));
		}
	}

	@Test
	public void testGenPDFDocument() throws Exception {//根据模版生成PDF文档
		System.out.println("******************1");
		byte[] dataBty = ClientUtil.readFileToByteArray(new File("C:\\Users\\Administrator\\Desktop\\商事登记\\新建文本文档 (7).xml"));//xml模版数据
		String templateNum = "2AB63EDBECCB9A78";//模版编号
		ChannelMessage message = anySignClientTool.genPDFDocument(templateNum, dataBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("C:\\Users\\Administrator\\Desktop\\商事登记\\新建文本文档 (7)-all.pdf"), message.getBody());
		}
	}

	@Test
	public void testGenPDFDocumentAndSign() throws Exception {//根据模版生成PDF文档且签章
		byte[] dataBty = ClientUtil.readFileToByteArray(new File("C:/Users/admin/Desktop/template-test/testData.xml"));//xml模版数据
		String templateNum = "2DA902A856F02819";//模版编号
		String ruleNum = "0";//签章规则编号
		ChannelMessage message = anySignClientTool.genPDFDocumentAndSign(templateNum, ruleNum, dataBty);
		System.out.println("状态码：" + message.getStatusCode());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("C:/Users/admin/Desktop/template-test/templat-field-out.pdf"), message.getBody());
		}
	}

	@Test
	public void testGenPDFDocumentAndSigns() throws Exception {//根据模版生成PDF文档且多规则签章
		byte[] dataBty = ClientUtil.readFileToByteArray(new File("C:/Users/admin/Desktop/template-test/testData.xml"));//xml模版数据
		String templateNum = "336D77CF3BB8531A";//模版编号
		List<String> ruleNumList = new ArrayList<String>();//
		String ruleNum = "473F63381A931BFE";//签章规则编号列表
		ruleNumList.add(ruleNum);
		ruleNum = "2400608F35D122D5";//签章规则编号列表
		ruleNumList.add(ruleNum);
		ChannelMessage message = anySignClientTool.genPDFDocumentAndSign(templateNum, ruleNumList, dataBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("结果信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("C:/Users/admin/Desktop/templat-field-out.pdf"), message.getBody());
		}
	}

	@Test
	public void testGenBarcodeAndPdf() throws Exception {//产生条形码+pdf
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("D:/未加批注前.pdf"));//pdf字节数组
		String ruleNum = "3594C3EF6E61203C";
		//String contents = FileUtils.readFileToString(new File("D:/redCross.xml"));
		String contents = "123456789";
		ChannelMessage message = anySignClientTool.genBarcode(ruleNum, contents, pdfBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("D:/test-out.pdf"), message.getBody());
		}
	}

	@Test
	public void testGenBarcodeAndPdfAndSign() throws Exception {//产生条形码+pdf+签章
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("C:/Users/admin/Desktop/testFile/179K.pdf"));//pdf字节数组
		String barcodeRuleNum = "BE1A1DDFE499B8A";
		String signSealRuleNum = "10F70D0942747AB5";
		String contents = FileUtils.readFileToString(new File("C:/Users/admin/Desktop/testFile/barcodeXML.xml"));
		ChannelMessage message = anySignClientTool.genBarcodeAndSign(barcodeRuleNum, signSealRuleNum, contents, pdfBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("C:/Users/admin/Desktop/testFile/179K-out.pdf"), message.getBody());
		}
	}

	@Test
	public void testGenBarcodeAndXML() throws Exception {//产生条形码+XML+DOCX
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("C:/esspdf-sample/barcodeXML.xml"));//xml字节数组
		String ruleNum = "34FE8CB40C30B43E";
		ChannelMessage message = anySignClientTool.genBarcode(ruleNum, pdfBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("c:/esspdf-sample/barcode-out-xml.pdf"), message.getBody());
		}
	}

	@Test
	public void testgGenBarcodeAndXMLAndSign() throws Exception {//产生条形码+XML+DOCX+签章
		byte[] xmlBty = ClientUtil.readFileToByteArray(new File("D:/redCross.xml"));//xml字节数组
		String barcodeRuleNum = "173BBA290DA7D7C";
		String signSealRuleNum = "37917701E47EB4AE";
		long begin = System.currentTimeMillis();
		ChannelMessage message = anySignClientTool.genBarcodeAndSign(barcodeRuleNum, signSealRuleNum, xmlBty);
		long end = System.currentTimeMillis();
		System.out.println("The running time:" + (end - begin) / 1000f + "s");
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("D:/demo.pdf"), message.getBody());
		}
	}

	@Test
	public void testGenBarcodeImageWithXML() throws Exception {//产生条形码图片
		byte[] xmlBty = ClientUtil.readFileToByteArray(new File("C:/Users/admin/Desktop/barcodeXML.xml"));//xml字节数组
		String ruleNum = "4C2C6D118541AAF8";
		ChannelMessage message = anySignClientTool.genBarcodeImage(ruleNum, xmlBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("C:/Users/admin/Desktop/qr.png"), message.getBody());
		}
	}

	@Test
	public void testGenBarcodeImageWithText() throws Exception {//产生条形码图片
		String content = "刘冠阳|500.00|助困|20140127|现场现金";
		String ruleNum = "2CD0CF4A40D7F1A2";
		ChannelMessage message = anySignClientTool.genBarcodeImage(ruleNum, content.getBytes("UTF-8"));
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("D:/qr2.png"), message.getBody());
		}
	}

	@Test
	public void testExportXmlData() throws Exception {//从PDF导出xml模板数据
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("C:/Users/admin/Desktop/BJCA-Template-Help/北京银行个人开卡申请表样例.pdf"));//PDF文件
		ChannelMessage message = anySignClientTool.exportXMLData(pdfBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("C:/Users/admin/Desktop/BJCA-Template-Help/testXmlData.xml"), message.getBody());
		}
	}

	@Test
	public void testPdfSignByWord() throws Exception {//word转PDF进行签章测试
		byte[] wordBty = ClientUtil.readFileToByteArray(new File("D:\\TDMS可信单证管理系统安装部署手册V1.1.doc"));//word字节数组
		String ruleNum = "0";//签章规则编号
		long begin = System.currentTimeMillis();
		ChannelMessage message = anySignClientTool.pdfSignByWord(ruleNum, wordBty);
		long end = System.currentTimeMillis();
		System.out.println("********************运行时间:" + (end - begin) / 1000f + "s");
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("D:\\TDMS可信单证管理系统安装部署手册V1.1_out.pdf"), message.getBody());
		}
	}

	@Test
	public void testGenPDFInvoiceAndSign() throws Exception {//根据票据模版产生PDF文档且签名，杭州第一人民医院定制
		byte[] dataBty = ClientUtil.readFileToByteArray(new File("C:/Users/admin/Desktop/xmlDemo.xml"));//xml模版数据
		String templateNum = "78C0C9EFB64AC923";//模版编号
		String ruleNum = "1A5E5D2447656A20";//签章规则编号
		String fileName = "20140505_31441927_14111";
		ChannelMessage message = anySignClientTool.genPDFInvoiceAndSign(templateNum, ruleNum, fileName, dataBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
	}

	@Test
	public void testGenClientSignDigest() throws Exception {//产生客户端PDF签名摘要数据
		List<ClientSignMessage> clientSignMessages = new ArrayList<ClientSignMessage>();
		ClientSignMessage clientSignMessage = new ClientSignMessage();
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("D:\\测试文档\\借款合同.pdf"));//pdf字节数组
		//    	String keyword = "申请人签字";
		// SM2
		//    	String signCert = "MIIErDCCBFOgAwIBAgIKLRAAAAAAAAVaujAKBggqgRzPVQGDdTBEMQswCQYDVQQGEwJDTjENMAsGA1UECgwEQkpDQTENMAsGA1UECwwEQkpDQTEXMBUGA1UEAwwOQmVpamluZyBTTTIgQ0EwHhcNMTUwMjA0MTYwMDAwWhcNMTYwMjA1MTU1OTU5WjBoMRQwEgYDVQQpDAsxMzI5ODc2NTQzMjEdMBsGA1UEAwwU5rWL6K+V6K+B5LmmKOa1i+ivlSkxDTALBgNVBAoMBEJKQ0ExFTATBgNVBAoMDOa1i+ivleivgeS5pjELMAkGA1UEBgwCQ04wWTATBgcqhkjOPQIBBggqgRzPVQGCLQNCAATpV4nYVfxwzjxtnyng6qrwO/evH5W4TiDQKaqZnV7OWY/2ZMwMVtf2Pc3fLfUQvQ/E4Xf3eN8QNRtcdLm8/ho0o4IDBzCCAwMwHwYDVR0jBBgwFoAUH+bP1I/FIiqXSimKFecWyZI0xLYwHQYDVR0OBBYEFHKqmJobumZM9dxXIJdMAAODEKxzMAsGA1UdDwQEAwIGwDCBmwYDVR0fBIGTMIGQMF+gXaBbpFkwVzELMAkGA1UEBhMCQ04xDTALBgNVBAoMBEJKQ0ExDTALBgNVBAsMBEJKQ0ExFzAVBgNVBAMMDkJlaWppbmcgU00yIENBMREwDwYDVQQDEwhjYTIxY3JsMjAtoCugKYYnaHR0cDovL2NybC5iamNhLm9yZy5jbi9jcmwvY2EyMWNybDIuY3JsMB0GCiqBHIbvMgIBAQEEDwwNSkoxMzI5ODc2NTQzMjBgBggrBgEFBQcBAQRUMFIwIwYIKwYBBQUHMAGGF09DU1A6Ly9vY3NwLmJqY2Eub3JnLmNuMCsGCCsGAQUFBzAChh9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RwinNAV9wPfyX43faG1xIJrAmDtfkMXG4EQb11j1YglNpoisLACVZmaCkEWHmoVMJ8RSWGCYMfqnB4OgC+iYeYW1QL86coCYaEgz6U4YJmeBdHRKw+SdRek3DXCqflDG9CwRn+d16GuiHuT3RakyIKoTK0vtyOfmJsnjPwtMT1aXF9o0AI8u6mwccIb4oPFFpMzjIQ6ikrcCgSVXPeuMekoKeQX6xhIiVUpNgNUo83s8LVFLnIcVgpeBty2aFyU8f5UdKTcpkVmcJiNkIqKVMwhNUSzuWeTcLmkU+55BXdxMoehkgjGqvTIO0oS8esEI+fzFL2gJNLYuwpK6bE0y93FoZu4VKUmgEOCa8ESaLUsoGVE1IY35LLwliTcotYJihpNyOYFNNp0KxW1UL1TUqlsW4ICl8vzMiYLI6kl0ra2hiHE0xgBUxpu+hjPb8WFXz+5Gn8XEluGuUnDwaFLtWZkJzXjPjKd3qOIGJRSJwg5YZXaKoRJXMP7z5EpIyZZqM6tEAnq/eVicaEjaFZJzuh9URzUeWciDRfTIl4Lvddk5zcRKRXkHNKddKUn/3ETlCjQzoE9s6iCXTqFDTXDarWy6rXw+pVtQpUL0ZVqndL6d9+6i2yeomrRHBcDNX6VLPiz0yPcysIO/ZHuAIxL2yloF3v6knK9SwPfGUpYPlF18CWDWFInZphkXiyfi1WqY0d7GOFGFm/TtaWRrtsU72q2c569rOgDa1oR0va0pr2tKhNrWpXy9oQRAAAOw==";
		float sealWidth = 100;
		float sealHeight = 100;
		/* String moveType = "1";
		String searchOrder = "2";
		clientSignMessage.setKeyword(keyword);
		clientSignMessage.setMoveType(moveType);
		clientSignMessage.setSearchOrder(searchOrder);
		clientSignMessage.setPdfBty(pdfBty);
		clientSignMessage.setFileUniqueId("111111111111");
		clientSignMessage.setHeightMoveSize(10);
		clientSignMessage.setMoveSize(300);*/
		clientSignMessage.setRuleType("2");
		clientSignMessage.setFileUniqueId("1111111111");
		clientSignMessage.setPdfBty(pdfBty);
		clientSignMessage.setMoveType("1");
		RectangleBean rectangleBean = new RectangleBean();
		rectangleBean.setPageNo(1);
		rectangleBean.setBottom(0f);
		rectangleBean.setRight(127f);
		rectangleBean.setTop(40f);
		clientSignMessage.setRectangleBean(rectangleBean);
		clientSignMessages.add(clientSignMessage);
		ChannelMessage message = anySignClientTool.genClientSignDigest(clientSignMessages, signCert, sealImg, sealWidth, sealHeight);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		System.out.println("摘要数据：" + new String(message.getBody()));
	}

	//产生客户端PDF签名
	@Test
	public void genClientSign() throws Exception {
		String json = "D:/测试文档/json.txt";
		String signDataJson = FileUtils.readFileToString(new File(json));
		ChannelMessage message = anySignClientTool.genClientSign(signDataJson);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			List<ClientSignBean> signBeanList = message.getClientSignList();
			for (ClientSignBean beanObj : signBeanList) {
				ClientUtil.writeByteArrayToFile(new File("D:/测试文档/" + beanObj.getSignUniqueId() + ".pdf"), beanObj.getPdfBty());
			}
		}
	}

	//doc、docx 转PDF ,且插入产生条形码+签章
	@Test
	public void testGenBarcodeAndSignByWord() throws Exception {
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("C:/Users/admin/Desktop/海南地税/停业税务事项通知书（带附表）.doc"));//pdf字节数组
		String barcodeRuleNum = "1D6B823D900DA0B0";
		String signSealRuleNum = "B501FDFA15AFDFE";
		String contents = "C:/Users/admin/Desktop/停业税务事项通知书（带附表）.pdf";
		ChannelMessage message = anySignClientTool.genBarcodeAndSignByWord(barcodeRuleNum, signSealRuleNum, contents, pdfBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("C:/Users/admin/Desktop/海南地税/停业税务事项通知书（带附表）.pdf"), message.getBody());
		}
	}

	//产生二维码图片与印章图片 外交部定制
	@Test
	public void testGenBarcodeAndSeal() throws Exception {
		String ruleNum = "393FA6ACCF8B43C8";//二维码规则编号
		byte[] contentBty = "外交部测试123".getBytes("UTF-8");//二维码内容
		String usercert = "MIIFhTCCBG2gAwIBAgIKGzAAAAAAAAagXTANBgkqhkiG9w0BAQUFADBSMQswCQYDVQQGEwJDTjENMAsGA1UECgwEQkpDQTEYMBYGA1UECwwPUHVibGljIFRydXN0IENBMRowGAYDVQQDDBFQdWJsaWMgVHJ1c3QgQ0EtMTAeFw0xNDA2MDIxNjAwMDBaFw0xNTA3MDIxNTU5NTlaMEoxCzAJBgNVBAYTAkNOMRIwEAYDVQQDDAnnjovmlofmmIwxJzAlBgkqhkiG9w0BCQEWGHdhbmd3ZW5jaGFuZ0BiamNhLm9yZy5jbjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA6UcNwaRzuSnkDI8UCPZvpGnje1rbXjM5FbXQ8KxPq0TxGF9//3w2diiaFHoMYDq6JMbmtMjfu0xxa6TpYm8EmB2v3b/MBpmSL5iJ1r+nLOa+8R+ZDGHdAbp0jTqaub7L1ZcUzLaS2jK5QV4YWKZUBndFsxPWFVzS0NY9+E8MYV0CAwEAAaOCAucwggLjMB8GA1UdIwQYMBaAFKw77K8Mo1AO76+vtE9sO9vRV9KJMB0GA1UdDgQWBBTtEV/CA4ThawTQcpyBG7AJLgAYmzALBgNVHQ8EBAMCBsAwga0GA1UdHwSBpTCBojBsoGqgaKRmMGQxCzAJBgNVBAYTAkNOMQ0wCwYDVQQKDARCSkNBMRgwFgYDVQQLDA9QdWJsaWMgVHJ1c3QgQ0ExGjAYBgNVBAMMEVB1YmxpYyBUcnVzdCBDQS0xMRAwDgYDVQQDEwdjYTNjcmwzMDKgMKAuhixodHRwOi8vbGRhcC5iamNhLm9yZy5jbi9jcmwvcHRjYS9jYTNjcmwzLmNybDAJBgNVHRMEAjAAMBEGCWCGSAGG+EIBAQQEAwIA/zAdBgUqVgsHAQQUU0YzMjA3MjQxOTgw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H/DXFZeuUxHIwJDE7+vgoJ63IXkbLAYEl17VHHiTgYJAsX3QjuAQ8vGPI=";
		ChannelMessage message = anySignClientTool.genBarcodeAndSeal(ruleNum, contentBty, dataSign, usercert);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			//安全二维码图片
			byte[] barcodeBty = message.getBody();
			System.out.println("****************barcodeBty length:" + barcodeBty.length);
			FileUtils.writeByteArrayToFile(new File("C:\\Users\\admin\\Desktop\\外交部项目\\qr.png"), barcodeBty);
		}
	}

	//安全二维码验证
	@Test
	public void testBarcodeVerify() throws Exception {
		String content = "093211A10000000000009959A20150212142535MEQCIAbrTA+iPyw5kaUV92ILWupOhM5ckfbw+iV6h4vGuTx9AiBRt0eemo/zAWjmmPLeZMowd5/JN+ZEz3C6pB3bVDAtZg==5YiY5Y2g5q2m";
		ChannelMessage message = anySignClientTool.barcodeVerify(content);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			String verifyInfo = new String(message.getBody());
			String[] data = verifyInfo.split("&&");
		
			String certDn = new String(new Base64Encoder().decode(data[0]), "UTF-8");
			System.out.println("**************签名证书主题：" + certDn);
			String signTime = data[1];
			System.out.println("**************签名时间：" + signTime);
			String plainData = new String(new Base64Encoder().decode(data[2]), "UTF-8");
			System.out.println("**************原文数据：" + plainData);
		}
	}

	//PDF转图片
	@Test
	public void testPdfToImages() throws Exception {
		byte[] pdfBty = FileUtils.readFileToByteArray(new File("C:\\Users\\admin\\Desktop\\pdf to image\\DSVS接口测试程序使用指南.pdf"));
		//支持gif、bmp、png、jpg/jpeg、tiff
		String formatName = "png";
		ChannelMessage message = anySignClientTool.pdfToImages(pdfBty, formatName);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			String imageStr = new String(message.getBody());
			String[] images = imageStr.split("&&");
			int i = 0;
			for (String image : images) {
				//二进制图片数组
				byte[] imageBty =new Base64Encoder().decode(image);
				File file = new File("C:/Users/admin/Desktop/pdf to image/temp_image_" + i + "." + formatName);
				FileUtils.writeByteArrayToFile(file, imageBty);
				i++;
			}
		}
	}

	// 图片转PDF签章
	@Test
	public void testImagesToPDFSign() throws Exception {
		byte[] imageBty1 = FileUtils.readFileToByteArray(new File("C:\\Users\\admin\\Desktop\\test-pdf\\2-200506160001.tif"));
		byte[] imageBty2 = FileUtils.readFileToByteArray(new File("C:\\Users\\admin\\Desktop\\test-pdf\\2-200506160002.tif"));
		List<ClientSignMessage> signMessageList = new ArrayList<ClientSignMessage>();
		ClientSignMessage signMessage = new ClientSignMessage();
		signMessage.setImageBty(imageBty1);
		signMessageList.add(signMessage);
		signMessage = new ClientSignMessage();
		signMessage.setImageBty(imageBty2);
		signMessageList.add(signMessage);
		List<String> ruleNumList = new ArrayList<String>();//
		String ruleNum = "537CA483849D4EF2";//签章规则编号列表
		ruleNumList.add(ruleNum);
		ChannelMessage message = anySignClientTool.pdfSignByImages(ruleNumList, signMessageList);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("C:\\Users\\admin\\Desktop\\test-pdf\\tiff-demo.pdf"), message.getBody());
		}
	}

	// 根据图片转PDF文件进行多页签章
	@Test
	public void testPdfMultiPageSignByImages() throws Exception {
		byte[] imageBty1 = FileUtils.readFileToByteArray(new File("C:\\Users\\admin\\Desktop\\test-pdf\\2-200506160001.tif"));
		byte[] imageBty2 = FileUtils.readFileToByteArray(new File("C:\\Users\\admin\\Desktop\\test-pdf\\2-200506160002.tif"));
		List<ClientSignMessage> signMessageList = new ArrayList<ClientSignMessage>();
		ClientSignMessage signMessage = new ClientSignMessage();
		signMessage.setImageBty(imageBty1);
		signMessageList.add(signMessage);
		signMessage = new ClientSignMessage();
		signMessage.setImageBty(imageBty2);
		signMessageList.add(signMessage);
		signMessage = new ClientSignMessage();
		signMessage.setImageBty(imageBty2);
		signMessageList.add(signMessage);
		signMessage = new ClientSignMessage();
		signMessage.setImageBty(imageBty2);
		signMessageList.add(signMessage);
		signMessage = new ClientSignMessage();
		signMessage.setImageBty(imageBty2);
		signMessageList.add(signMessage);
		//签章规则编号列表
		String ruleNum = "54236EE630F95598";
		ChannelMessage message = anySignClientTool.pdfMultiPageSignByImages(ruleNum, signMessageList, "北京数字认证");
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("C:\\Users\\admin\\Desktop\\test-pdf\\tiff-demo.pdf"), message.getBody());
		}
	}

	// PDF多页签章
	@Test
	public void testPdfMultiPageSign() throws Exception {
		System.out.println("*****************");
		byte[] pdfBty = FileUtils.readFileToByteArray(new File("D:\\test.pdf"));
		String ruleNum = "5E9217F50C3E491D";
		ChannelMessage message = anySignClientTool.pdfMultiPageSign(ruleNum, pdfBty, "北京数字认证");
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("D:\\test-out.pdf"), message.getBody());
		}
	}

	// PDF添加签名域
	@Test
	public void testGenSignField() throws Exception {//pdf
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("C:\\Users\\Liuyan\\Desktop\\商事登记\\新建文本文档 (7)-simsun.pdf"));//pdf字节数组
		String ruleNum = "63DEB0EABC70501C";
		// String contents = FileUtils.readFileToString(new File("d:/pdfs/sftest/templateData.xml"));
		// String contents ="<root/>";
		ChannelMessage message = anySignClientTool.genSignField(ruleNum, null, pdfBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("C:\\Users\\Liuyan\\Desktop\\商事登记\\新建文本文档 (7)-simsun-field.pdf"), message.getBody());
		}
	}

	// doc/docx 转PDF ,且添加签名域
	@Test
	public void testSignFieldByXML() throws Exception {
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("C:\\Users\\Liuyan\\Desktop\\商事登记\\新建文本文档 (7).xml"));//xml字节数组
		String barcodeRuleNum = "B60FF391AA60CBC";
		ChannelMessage message = anySignClientTool.genSignFieldByXML(barcodeRuleNum, pdfBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("C:\\Users\\Liuyan\\Desktop\\商事登记\\新建文本文档 (7)-STZHONGS.pdf"), message.getBody());
		}
	}

	// PDF去公章测试
	@Test
	public void testClearSignature() throws Exception {
		System.out.println("******************123");
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("C:\\Users\\admin\\Desktop\\KiraTest20150901000002.pdf"));//pdf字节数组
		ChannelMessage message = anySignClientTool.clearSignature(pdfBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("d:/test.pdf"), message.getBody());
		}
	}

	@Test
	public void gbkConvertToUTF8() throws Exception {
		byte[] gbkBty = FileUtils.readFileToByteArray(new File("C:\\Users\\admin\\Desktop\\barcodeXML.xml"));
		byte[] utf8Bty = anySignClientTool.gbkConvertToUTF8(gbkBty);
		FileUtils.writeByteArrayToFile(new File("C:\\Users\\admin\\Desktop\\barcodeXML-utf8.xml"), utf8Bty);
	}

	// 从XFA表单导出XML数据
	@Test
	public void testExportXFAXmlData() throws Exception {
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("D:/testXFA.pdf"));
		ChannelMessage message = anySignClientTool.exportXFAXMLData(pdfBty);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("D:/test.xml"), message.getBody());
		}
	}

	@Test
	public void testPdfSignByParam() throws Exception {
		byte[] pdfBty = ClientUtil.readFileToByteArray(new File("D:/b.pdf"));
		RectangleBean bean = new RectangleBean();
		bean.setPageNo(1);
		bean.setLeft(200f);
		bean.setTop(300f);
		bean.setRight(300f);
		bean.setBottom(200f);
		ChannelMessage message = anySignClientTool.pdfSignByParam(pdfBty, "5E9217F50C3E491D", bean);
		System.out.println("状态码：" + message.getStatusCode());
		System.out.println("状态信息：" + message.getStatusInfo());
		if ("200".equals(message.getStatusCode())) {//成功
			ClientUtil.writeByteArrayToFile(new File("D:\\ClientSign.pdf"), message.getBody());
		}
	}

}
